Fix Fuentes int input truncation by forcing float dtype#2618
Fix Fuentes int input truncation by forcing float dtype#2618kumaradityaapril wants to merge 1 commit intopvlib:mainfrom
Conversation
|
@kumaradityaapril please address the formatting issues identified by Flake8. There are two tests that use the |
|
Thanks for the review. I’ll address the Flake8 formatting issues and update the Fuentes-related tests. For the tests that use the Fuentes model, I’ll recompute the expected values using the corrected fuentes implementation and update the hard-coded expectations (with sufficient precision) so that they pass with the default rtol and atol settings, without relaxing tolerances. |
|
Closing due to lack of progress. |
Closes #2608
Summary
This PR fixes a dtype-dependent bug in
pvlib.temperature.fuenteswhere integerpoa_globalinputs could lead to truncated module temperatures and slightly different results compared to float inputs with the same numeric values.Changes
In
pvlib.temperature.fuentes:tmod_array = np.zeros_like(poa_global)totmod_array = np.zeros_like(poa_global, dtype=float)so internal temperature calculations always use a float dtype.In
tests/test_temperature.py:test_fuentes_int_float_consistency, which callsfuenteswith both integer and floatpoa_globalseries (same values, datetime index) and asserts that the results match within floating-point tolerance.Rationale
Previously, when
poa_globalwas an integer Series,tmod_arraywas also integer, so intermediate temperatures such as321.19 Kwere truncated to321when stored. Converting to Celsius (tmod_array - 273.15) produced a different value than for float inputs.This change ensures that physically identical inputs (
100vs100.0) produce identical Fuentes outputs.Testing
pytest tests/test_temperature.py::test_fuentes -vpytest tests/test_temperature.py::test_fuentes_int_float_consistency -v